<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>测试vue响应式</title>
  <script src="./vue.js"></script>
</head>
<body>
  <div id="app">
    {{msg}}
  </div>
  <script>
    var data = {
      name: 1
    }
    var vm = new Vue({
      el: '#app',
      data: data
    })

    vm.$watch('name', function(newValue, oldValue){
     console.log(newValue, oldValue);
     if(newValue == oldValue) {
       console.log("same");
     } else {
       console.log("dif");
     }
    })
    vm.$data.name = 2;

    
  </script>
</body>
</html>